import os
import dotenv
from langchain_openai import ChatOpenAI
import streamlit as st

dotenv.load_dotenv()
openai_url = os.getenv('OPENAI_API_BASE')
api_key = os.getenv('OPENAI_API_KEY')

st.set_page_config(page_title="智能问答")
st.header("智能问答")
user_question = st.text_input("来向我提问吧：")

if user_question:
  llm = ChatOpenAI(openai_api_key=api_key,openai_api_base=openai_url)
  response = llm.invoke(user_question)
  st.write(response.content)


# llm = ChatOpenAI(openai_api_key=api_key,openai_api_base=openai_url)
# res = llm.invoke("你是谁?")
# print(res)